spi: cadence_qspi: Ensure check for max frequency in place
authorChin Liang See <[email protected]>
Sat, 17 Oct 2015 13:32:38 +0000 (08:32 -0500)
committerMarek Vasut <[email protected]>
Thu, 5 Nov 2015 01:34:15 +0000 (02:34 +0100)
Ensure the intended SCLK frequency not exceeding the maximum
frequency. If that happen, SCLK will set to maximum frequency.

Signed-off-by: Chin Liang See <[email protected]>
Cc: Dinh Nguyen <[email protected]>
Cc: Dinh Nguyen <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Stefan Roese <[email protected]>
Cc: Vikas Manocha <[email protected]>
Cc: Jagannadh Teki <[email protected]>
Cc: Pavel Machek <[email protected]>
Acked-by: Pavel Machek <[email protected]>
drivers/spi/cadence_qspi.c

index 575617876103f9d318c5c0212e673b73ab2f02d7..4f7fd5253220882c7074ac62bdcb5e4461a48b07 100644 (file)
@@ -122,6 +122,9 @@ static int cadence_spi_set_speed(struct udevice *bus, uint hz)
        struct cadence_spi_priv *priv = dev_get_priv(bus);
        int err;
 
+       if (hz > plat->max_hz)
+               hz = plat->max_hz;
+
        /* Disable QSPI */
        cadence_qspi_apb_controller_disable(priv->regbase);